import junit.framework.TestCase;
import de.unibi.comet.ac.SuffixArrayFactory;

public class SuffixArrayFactoryTest extends TestCase {
	public void testSuffixArrayConstruction() {
		int[] sa = SuffixArrayFactory.create("mississippi");
		assertEquals(11, sa.length);
		assertEquals(10, sa[0]);
		assertEquals(7, sa[1]);
		assertEquals(4, sa[2]);
		assertEquals(1, sa[3]);
		assertEquals(0, sa[4]);
		assertEquals(9, sa[5]);
		assertEquals(8, sa[6]);
		assertEquals(6, sa[7]);
		assertEquals(3, sa[8]);
		assertEquals(5, sa[9]);
		assertEquals(2, sa[10]);
	}
	
	public void testIntSuffixArrayConstruction() {
		fail("Fix integer suffix array construction");
		int[] s_array = {'m', 'i', 's', 's', 'i', 's', 's', 'i', 'p', 'p', 'i'};
		for (int i=0; i<s_array.length; ++i) s_array[i]+=396;
		
		int[] sa = SuffixArrayFactory.create(s_array);
		assertEquals(11, sa.length);
		assertEquals(10, sa[0]);
		assertEquals(7, sa[1]);
		assertEquals(4, sa[2]);
		assertEquals(1, sa[3]);
		assertEquals(0, sa[4]);
		assertEquals(9, sa[5]);
		assertEquals(8, sa[6]);
		assertEquals(6, sa[7]);
		assertEquals(3, sa[8]);
		assertEquals(5, sa[9]);
		assertEquals(2, sa[10]);		
	}
	
}
